package com.zdkj.subway.check.service.impl.subwayRat.cashboxUninstall;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.zdkj.subway.check.mapper.CashboxUninstallMapper;
import com.zdkj.subway.check.mapper.SysUserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import javax.annotation.Resource;
import java.util.Map;

@Service
@Slf4j
@Transactional(rollbackFor = Exception.class)
public class CashboxUninstallServiceImpl {

    @Autowired
    private CashboxUninstallMapper cashboxUninstallMapper;
    @Resource
    private SysUserMapper sysUserMapper;

    /**
     * 钱箱未卸载
     * @param page
     * @param param
     * @return
     */
    public IPage<Map<String,Object>> getCashboxUninstallList(Page page, Map<String,Object> param) {
        /*Map<String,Object> p1=new HashMap<>();
        String lineCode = param.get("lineCode");
        String stationCode = param.get("stationCode");
        if(StringUtils.isNotEmpty(lineCode) || StringUtils.isNotEmpty(stationCode)){
            List<Map<String, Object>> maps = cashboxUninstallMapper.getCashboxUninstallList(param);
            return maps;
        }
        p1.put("user_code", UserInfo.getUserCode());
        List<SysUser> sysUsers = sysUserMapper.selectByMap(p1);
        SysUser sysUser = sysUsers.get(0);
        String managementLineStation = sysUser.getManagementLineStation();
        managementLineStation= StringUtils.isEmpty(managementLineStation)?"[]":managementLineStation;
        JSONArray managementLineStations = JSONArray.parseArray(managementLineStation);
        List<Map<String,Object>> casboxUninstallList=new ArrayList<>();
        for(int i=0;i<managementLineStations.size();i++){
            JSONObject jsonObject = managementLineStations.getJSONObject(i);
            String line = jsonObject.getString("line");
            String station = jsonObject.getString("station");
            param.put("lineCode",line);
            param.put("stationCode",station);
            List<Map<String,Object>> reportErrorAlterAppayOne = cashboxUninstallMapper.getCashboxUninstallList(param);
            casboxUninstallList.addAll(reportErrorAlterAppayOne);
        }*/
        IPage<Map<String, Object>> reportErrorAlterAppayOne = cashboxUninstallMapper.getCashboxUninstallList(page,param);
        return reportErrorAlterAppayOne;
    }
}
